using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BackgroundMove : MonoBehaviour
{

    public Transform bg1;
    public Transform bg2;

    private readonly float startPoint_X=24.5f;
    private readonly float endPoint_X=-24.5f;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if(GMGlobal.Instance.birdStatus!=0)
        {
            BgMove();
            GMGlobal.Instance.flight+=Time.deltaTime;
        }
    }

    private void BgMove()
    {
        if(bg1.position.x<endPoint_X)
        {
            bg1.position=new Vector2(startPoint_X,1);;
        }
        if(bg2.position.x<endPoint_X)
        {
            bg2.position=new Vector2(startPoint_X,1);;
        }
        float v=GMGlobal.Instance.velocity;
        bg1.Translate(Vector2.left/50*v);
        bg2.Translate(Vector2.left/50*v);
    }


}
